package com.controller;


import com.Service.userService;
import com.model.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

import javax.jws.soap.SOAPBinding;
import javax.servlet.http.HttpSession;
import java.util.List;


@Controller
@RequestMapping("Login")
public class UserController {
    @Resource
    private userService userService;
    private User iuser;


    @RequestMapping("Login")
    public String Login(User user, HttpSession session){
        session.removeAttribute("err");
            user = userService.Login(user);
           session.setAttribute("user",user);
        if(user!=null){

            return "index";
        }else{


            session.setAttribute("err","错误");
            return "index";
        }

    }
    @RequestMapping("update")
    public String updata(User user,HttpSession session){

        session.setAttribute("user",user);
        return "updatepwdq";
    }
    @RequestMapping("updatepwd")
    public String updatapwd(User user,  String pwd, HttpSession session){

        iuser = userService.Login(user);
        String name=user.getUserName();
        if (iuser!=null){
            int i=userService.update(name,pwd);
            return "index";
        }else {
            System.out.println("111112222");
            return "redirect:/Login/update";
        }

    }

}
